Skip to content

Instantly share code, notes, and snippets.

@anildigital
anildigital / cleanup_swap.md
Last active May 14, 2024 08:28
Cleanup swap space on macOS

To see current swap usage

sysctl -a | grep swap

Use only when when your system is in a very bad shape

$ sudo pkill -HUP -u _windowserver 
@xarinatan
xarinatan / networked pulseaudio.md
Last active May 14, 2024 08:25
How to set up PulseAudio over Network

How to set up PulseAudio over Network

PulseAudio actually has great networking capabilities. Especially when combined with Avahi/Zeroconf it is especially easy to set up, though technically it should also be possible without.

Setting up the server

  • Open /etc/pulseaudio/default.pa
  • At the end of the file, add load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.254.0/24 auth-anonymous=1 to activate networked audio from 192.168.254.0-255 without needing authentication.
  • Kill pulseaudio, it should be auto-restarted, or restart your login session to activate the changes. You should now be able to set PULSE_SERVER=192.168.254.XXX and have the remote audio working! If not check the firewall settings, PulseAudio seems to open a random port by default.

Setting up automatic configuration and discovery

  • On both the server and client, install pulseaudio-module-zeroconf and avahi, then after installing make sure Avahi always runs by running systemctl enable --now avahi-daemon
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active May 14, 2024 08:25
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@wojteklu
wojteklu / clean_code.md
Last active May 14, 2024 08:23
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@sempr
sempr / codeforces-sample-download.user.js
Created May 14, 2024 05:56
Codeforces Data Donwloader
// ==UserScript==
// @name Codeforces Data Donwloader
// @namespace http://tampermonkey.net/
// @version 2024-05-14
// @description Download Script For Codeforces
// @author Sempr
// @match https://codeforces.com/contest/*/problems
// @icon https://aowuucdn.oss-accelerate.aliyuncs.com/codeforces.png
// @grant GM_addStyle
// @require https://cdnjs.cloudflare.com/ajax/libs/jszip/3.7.1/jszip.min.js
@ardecvz
ardecvz / vcr_intro.rb
Last active May 14, 2024 08:22
A VCR trick to include preparation and cleanup phases for external services directly within the test files (the phases run ONLY when recording cassettes)
# frozen_string_literal: true
# A VCR trick to include preparation and cleanup phases for external services
# directly within the test files (the phases run ONLY when recording cassettes):
#
# RSpec.describe EvilMartiansAPI::Client, vcr: true do
# let(:client) { described_class.new }
#
# let(:developer_team_number) { 42 }
#
@Verssae
Verssae / skip.js
Last active May 14, 2024 08:22
한양대학교 인권/폭력예방 교육시스템 스킵 스크립트
/**
[강의 영상 스킵]
1. 재생버튼을 눌러 한양대 로딩 영상이 끝나고(약 4초) 강의가 재생된 후 F12 버튼을 눌러 개발자 콘솔을 연 뒤 console 탭으로 이동한다.
2. 아래 스크립트를 붙여넣는다.
3. 사이트에서 나갈 것이냐고 묻는 창이 뜨면 '나가기'를 누른다.
4. 다시 영상이 로드되면 재생 버튼을 눌러 재생하고 영상 끝으로 컨트롤 버튼을 움직여 영상 시청을 완료한다.
**/
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 14, 2024 08:22
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@xiabingquan
xiabingquan / flash_attention_in_numpy.py
Last active May 14, 2024 08:22
An toy example of flash attention implemented with Numpy.
# A minimal exmaple of flash attention implemented in Numpy
# Contact: bingquanxia AT qq.com
import unittest
from typing import List
import numpy as np
import torch